const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
  entry: './src/main.js',
  output: { 
    path: path.resolve(__dirname, "dist"), // 出口路径
    filename: "bundle.js" ,// 出口文件名
    clean:true, // 每次打包前先清空出口文件夹
  },
  plugins: [
    new HtmlWebpackPlugin({
      template:'./public/index.html'
    })
  ],
  module: {
    rules: [
      {
        test: /\.css$/i,
        use:["style-loader","css-loader"]
      },
      {
        test: /\.less$/i,
        use: [
          'style-loader',
          'css-loader',
          'less-loader'
        ],
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        type: 'asset/resource',
      },
      {
        test: /\.(woff|woff2|eot|ttf|otf|svg)$/i,
        type: 'asset/resource',
        generator: {
          filename:'fonts/[name].[hash:6][ext]'
        }
      },
    ],
  }
  
};